<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML>
<HEAD>
  <style>
  * { margin:0px; padding:0px; border-width:0px;}

  body {
    height:100%;
    width:100%;
    overflow: hidden;
  }

  #main {
    position: absolute;
    top: 0px;
    left: 0px;
    height:100%;
    width:300%;
    overflow: hidden;

    font-size: 11px;
    font-family: "lucida grande",tahoma,verdana,arial,sans-serif;

  }

  .messenger 
  {
    float:left;
    cursor:pointer;
    padding:3px;
    overflow: hidden;
    background-color:Cornsilk; 
    border-width:1px; 
    border-color:Brown;
    border-style:solid;
    
    width:192px;
    height: 56px;

    margin-left:6px;
  }

  .messenger:first-child
  {
    margin-left: 0px;
  }

  .messenger:hover *
  {
    /*margin-left: 128px;
    background-color:red;*/
    /*display:none;*/
    /*z-index:1000;*/
  }

  .head 
  {
    float:left; 
    /*
    float:left; 
    height:32px;
    width:64px;
    overflow: hidden;*/
  }

  .body 
  {
    padding-left:54px;
    /*
    background-color: Pink;
    height:32px;
    width:128px;
    padding-left:64;
    overflow: hidden;*/
  }

  .header 
  { 
    color:#3B5998;
    font-weight: bold;
  }

  .action
  { 
    /*margin-left:3px;*/
  }

  .content 
  { 
    /*margin-left:3px;*/
    font-style:italic;
  }
  .footer 
  {
    /*margin-left:3px;*/
  }
  </style>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <script src="./core/event.js"></script>
<script>

function OnPublish(m)
{
  var mdiv = document.createElement("div");
  mdiv.setAttribute("id", m.identity);
  mdiv.setAttribute("class", "messenger");

  if ( m.content.category == "private-chat" )
  {
    var head = document.createElement("div");
    head.setAttribute("class", "head");
    if ( m.content.picture )
    {
      mpic = document.createElement("img");
      mpic.setAttribute("src", m.content.picture);
      head.appendChild(mpic);
    }

    var body = document.createElement("div");
    body.setAttribute("class", "body");

    var header = document.createElement("span");
    header.setAttribute("class", "header");
    header.appendChild( document.createTextNode(m.content.head + " ") );

    var action = document.createElement("span");
    action.setAttribute("class", "action");
    action.appendChild( document.createTextNode("отправил вам сообщение: ") );
    
    var content = document.createElement("span");
    content.setAttribute("class", "content");
    content.appendChild( document.createTextNode(m.content.text) );
    
    var footer = document.createElement("span");
    footer.setAttribute("class", "footer");

    body.appendChild(header);
    body.appendChild(action);
    body.appendChild(content);
    body.appendChild(footer);

    mdiv.appendChild(head);
    mdiv.appendChild(body);
    document.getElementById("main").appendChild(mdiv);
    
    Event.add(mdiv, "click", function() { launcher.exec("private-chat", m.content.params); });
  }
}

function update()
{
  var newChannel = "";

  if ( model.me && model.me.id ) newChannel = "faceonline.notifier." + model.me.id;
  else newChannel = "";

  if ( window.channelName == newChannel)
    return;

  if ( window.channelName )
  {
    comet.describe( window.channelName, OnPublish);
    comet.close( window.channelName );
  }

  window.channelName = newChannel;
    
  if ( window.channelName )
  {
    comet.subscribe( window.channelName, OnPublish );
    comet.open( { channel: window.channelName } );
  }
}

function OnLoad()
{
  try
  {
    
    window.fo = window.parent.fo;
    window.comet = fo.comet;
    window.model = fo.model;
    window.launcher = fo.launcher;
    fo.ctrl.me.subscribe(window);
    
  }
  catch(e)
  {
    alert(e.message);
  }
}

Event.add(window, 'load', OnLoad)

</script>
</HEAD>
<BODY>
<div id = "main">
</div>
</BODY>
</HTML>
